package com.lineage.server.timecontroller.pet;

import com.lineage.server.model.Instance.L1HierarchInstance;
import com.lineage.server.thread.GeneralThreadPool;
import com.lineage.server.world.WorldHierarch;
import java.util.Collection;
import java.util.Iterator;
import java.util.TimerTask;
import java.util.concurrent.ScheduledFuture;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class HierarchTimer extends TimerTask {
  private static final Log _log = LogFactory.getLog(HierarchTimer.class);
  
  private ScheduledFuture<?> _timer;
  
  public void start() {
    int timeMillis = 10000;
    this._timer = GeneralThreadPool.get().scheduleAtFixedRate(this, 10000L, 10000L);
  }
  
  public void run() {
    try {
      Collection<L1HierarchInstance> allHierarch = WorldHierarch.get().all();
      if (allHierarch.isEmpty())
        return; 
      Iterator<L1HierarchInstance> iter = allHierarch.iterator();
      L1HierarchInstance l1HierarchInstance = null;
      while (iter.hasNext())
         l1HierarchInstance = iter.next(); 
    	} catch (Exception e) {
      _log.error("祭司处理时间轴异常重启", e);
      GeneralThreadPool.get().cancel(this._timer, false);
      HierarchTimer hierarch_Timer = new HierarchTimer();
      hierarch_Timer.start();
    } 
  }
  
  private static void outHierarch(L1HierarchInstance hierarch) {
    try {
      if (hierarch != null) {
        if (hierarch._destroyed)
          return; 
        hierarch.deleteHierarch();
      } 
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
    } 
  }
}
